package com.fanghaoran.notes.websocket;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * @Author: win11
 * @Date: 2023/05/04/16:10
 * @Description:
 */
public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator {

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        HttpSession httpSession =(HttpSession) request.getHttpSession();
        //将httpSession存到config
        sec.getUserProperties().put(HttpSession.class.getName(),httpSession);
    }
}
